
%include 'C:\Users\maggi\Documents\Manuscript\Work from home\Programs\WFH.sas'; *call in the datastep codes;

**********************************************************************************************
                                        TABLE 3
********************************************************************************************** ;

data table3;
set wellbeing;

work_home2018d2=(work_home2018d=2); work_home2018d1=(work_home2018d=1); 

format work_home2018e work_home2018e. race22018c race22018c. age_cat2018c age_cat2018c. gender2018 gender2018c. mart_status2018c mart_status2018c. educ2018c educ2018c. 
home2018c home2018c. no_animal2018c no_animal2018c. work_hours2018c work_hours2018c.;

/*3-category of WFH*/

*gender;
%macro linear(outcome);
proc glm data=table3;
class race22018c age_cat2018c gender2018(ref='male') mart_status2018c educ2018c home2018c no_animal2018c work_hours2018c/ref=first;
model &outcome.= work_home2018d1 work_home2018d2 work_home2018d1*gender2018 work_home2018d2*gender2018
                 gender2018 n_children2018z n_elders2018z no_animal2018c purpose2018z
                 work_hours2018c w_meaning2018z w_recognized2018z w_team2018z 
                 age_cat2018c  race22018c mart_status2018c educ2018c home2018c depressed2018z physhlth2018z 
                 distracted2018_rz w_productive2018z wkfamilyconfl2018z jobsatis2018z /solution clparm; 
title "&outcome.";
run;
%mend;

%linear(outcome=distracted2019_rz);
%linear(outcome=w_productive2019z);
%linear(outcome=wkfamilyconfl2019z);
%linear(outcome=jobsatis2019z);
run;

*#Children;
%macro linear(outcome);
proc glm data=table3;
class race22018c age_cat2018c gender2018(ref='male') mart_status2018c educ2018c home2018c no_animal2018c work_hours2018c/ref=first;
model &outcome.= work_home2018d1 work_home2018d2 work_home2018d1*n_children2018z work_home2018d2*n_children2018z
                 gender2018 n_children2018z n_elders2018z no_animal2018c purpose2018z
                 work_hours2018c w_meaning2018z w_recognized2018z w_team2018z 
                 age_cat2018c  race22018c mart_status2018c educ2018c home2018c depressed2018z physhlth2018z 
                 distracted2018_rz w_productive2018z wkfamilyconfl2018z jobsatis2018z /solution clparm; 
title "&outcome.";
run;
%mend;

%linear(outcome=distracted2019_rz);
%linear(outcome=w_productive2019z);
%linear(outcome=wkfamilyconfl2019z);
%linear(outcome=jobsatis2019z);
run;

*Children (y vs. n);
%macro linear(outcome);
proc glm data=table3;
class race22018c age_cat2018c gender2018(ref='male') n_children2018c mart_status2018c educ2018c home2018c no_animal2018c work_hours2018c/ref=first;
model &outcome.= work_home2018d1 work_home2018d2 work_home2018d1*n_children2018c work_home2018d2*n_children2018c
                 gender2018 n_children2018c elders2018c no_animal2018c purpose2018z
                 work_hours2018c w_meaning2018z w_recognized2018z w_team2018z 
                 age_cat2018c  race22018c mart_status2018c educ2018c home2018c depressed2018z physhlth2018z 
                 distracted2018_rz w_productive2018z wkfamilyconfl2018z jobsatis2018z /solution clparm; 
title "&outcome.";
run;
%mend;

%linear(outcome=distracted2019_rz);
%linear(outcome=w_productive2019z);
%linear(outcome=wkfamilyconfl2019z);
%linear(outcome=jobsatis2019z);
run;

*#elderly;
%macro linear(outcome);
proc glm data=table3;
class race22018c age_cat2018c gender2018(ref='male') mart_status2018c educ2018c home2018c no_animal2018c work_hours2018c/ref=first;
model &outcome.= work_home2018d1 work_home2018d2 work_home2018d1*n_elders2018z work_home2018d2*n_elders2018z
                 gender2018 n_children2018z n_elders2018z no_animal2018c purpose2018z
                 work_hours2018c w_meaning2018z w_recognized2018z w_team2018z 
                 age_cat2018c  race22018c mart_status2018c educ2018c home2018c depressed2018z physhlth2018z 
                 distracted2018_rz w_productive2018z wkfamilyconfl2018z jobsatis2018z /solution clparm; 
title "&outcome.";
run;
%mend;

%linear(outcome=distracted2019_rz);
%linear(outcome=w_productive2019z);
%linear(outcome=wkfamilyconfl2019z);
%linear(outcome=jobsatis2019z);
run;

*elderly (y vs. n);
%macro linear(outcome);
proc glm data=table3;
class race22018c age_cat2018c gender2018(ref='male') mart_status2018c educ2018c home2018c no_animal2018c work_hours2018c elders2018c/ref=first;
model &outcome.= work_home2018d1 work_home2018d2 work_home2018d1*elders2018c work_home2018d2*elders2018c
                 gender2018 n_children2018c elders2018c no_animal2018c purpose2018z
                 work_hours2018c w_meaning2018z w_recognized2018z w_team2018z 
                 age_cat2018c  race22018c mart_status2018c educ2018c home2018c depressed2018z physhlth2018z 
                 distracted2018_rz w_productive2018z wkfamilyconfl2018z jobsatis2018z /solution clparm; 
title "&outcome.";
run;
%mend;

%linear(outcome=distracted2019_rz);
%linear(outcome=w_productive2019z);
%linear(outcome=wkfamilyconfl2019z);
%linear(outcome=jobsatis2019z);
run;

*pet;
%macro linear(outcome);
proc glm data=table3;
class race22018c age_cat2018c gender2018(ref='male') mart_status2018c educ2018c home2018c no_animal2018c(ref='no pet') work_hours2018c/ref=first;
model &outcome.= work_home2018d1 work_home2018d2 work_home2018d1*no_animal2018c work_home2018d2*no_animal2018c
                 gender2018 n_children2018z n_elders2018z no_animal2018c purpose2018z
                 work_hours2018c w_meaning2018z w_recognized2018z w_team2018z 
                 age_cat2018c  race22018c mart_status2018c educ2018c home2018c depressed2018z physhlth2018z 
                 distracted2018_rz w_productive2018z wkfamilyconfl2018z jobsatis2018z /solution clparm; 
title "&outcome.";
run;
%mend;

%linear(outcome=distracted2019_rz);
%linear(outcome=w_productive2019z);
%linear(outcome=wkfamilyconfl2019z);
%linear(outcome=jobsatis2019z);
run;

*purpose;
%macro linear(outcome);
proc glm data=table3;
class race22018c age_cat2018c gender2018(ref='male') mart_status2018c educ2018c home2018c no_animal2018c work_hours2018c/ref=first;
model &outcome.= work_home2018d1 work_home2018d2 work_home2018d1*purpose2018z work_home2018d2*purpose2018z
                 gender2018 n_children2018z n_elders2018z no_animal2018c purpose2018z
                 work_hours2018c w_meaning2018z w_recognized2018z w_team2018z 
                 age_cat2018c  race22018c mart_status2018c educ2018c home2018c depressed2018z physhlth2018z 
                 distracted2018_rz w_productive2018z wkfamilyconfl2018z jobsatis2018z /solution clparm; 
title "&outcome.";
run;
%mend;

%linear(outcome=distracted2019_rz);
%linear(outcome=w_productive2019z);
%linear(outcome=wkfamilyconfl2019z);
%linear(outcome=jobsatis2019z);
run;

*work hours (continuous);
%macro linear(outcome);
proc glm data=table3;
class race22018c age_cat2018c gender2018(ref='male') mart_status2018c educ2018c home2018c no_animal2018c/ref=first;
model &outcome.= work_home2018d1 work_home2018d2 work_home2018d1*work_hours2018c work_home2018d2*work_hours2018c
                 gender2018 n_children2018z n_elders2018z no_animal2018c purpose2018z
                 work_hours2018c w_meaning2018z w_recognized2018z w_team2018z 
                 age_cat2018c  race22018c mart_status2018c educ2018c home2018c depressed2018z physhlth2018z 
                 distracted2018_rz w_productive2018z wkfamilyconfl2018z jobsatis2018z /solution clparm; 
title "&outcome.";
run;
%mend;

%linear(outcome=distracted2019_rz);
%linear(outcome=w_productive2019z);
%linear(outcome=wkfamilyconfl2019z);
%linear(outcome=jobsatis2019z);
run;

*work hours (categorical);
%macro linear(outcome);
proc glm data=table3;
class race22018c age_cat2018c gender2018(ref='male') mart_status2018c educ2018c home2018c no_animal2018c work_hours2018c/ref=first;
model &outcome.= work_home2018d1 work_home2018d2 work_home2018d1*work_hours2018c work_home2018d2*work_hours2018c
                 gender2018 n_children2018z n_elders2018z no_animal2018c purpose2018z
                 work_hours2018c w_meaning2018z w_recognized2018z w_team2018z 
                 age_cat2018c  race22018c mart_status2018c educ2018c home2018c depressed2018z physhlth2018z 
                 distracted2018_rz w_productive2018z wkfamilyconfl2018z jobsatis2018z /solution clparm; 
title "&outcome.";
run;
%mend;

%linear(outcome=distracted2019_rz);
%linear(outcome=w_productive2019z);
%linear(outcome=wkfamilyconfl2019z);
%linear(outcome=jobsatis2019z);
run;

*meaning;
%macro linear(outcome);
proc glm data=table3;
class race22018c age_cat2018c gender2018(ref='male') mart_status2018c educ2018c home2018c no_animal2018c/ref=first;
model &outcome.= work_home2018d1 work_home2018d2 work_home2018d1*w_meaning2018z work_home2018d2*w_meaning2018z
                 gender2018 n_children2018z n_elders2018z no_animal2018c purpose2018z
                 work_hours2018c w_meaning2018z w_recognized2018z w_team2018z 
                 age_cat2018c  race22018c mart_status2018c educ2018c home2018c depressed2018z physhlth2018z 
                 distracted2018_rz w_productive2018z wkfamilyconfl2018z jobsatis2018z /solution clparm; 
title "&outcome.";
run;
%mend;

%linear(outcome=distracted2019_rz);
%linear(outcome=w_productive2019z);
%linear(outcome=wkfamilyconfl2019z);
%linear(outcome=jobsatis2019z);
run;

*recognition;
%macro linear(outcome);
proc glm data=table3;
class race22018c age_cat2018c gender2018(ref='male') mart_status2018c educ2018c home2018c no_animal2018c/ref=first;
model &outcome.= work_home2018d1 work_home2018d2 work_home2018d1*w_recognized2018z work_home2018d2*w_recognized2018z
                 gender2018 n_children2018z n_elders2018z no_animal2018c purpose2018z
                 work_hours2018c w_meaning2018z w_recognized2018z w_team2018z 
                 age_cat2018c  race22018c mart_status2018c educ2018c home2018c depressed2018z physhlth2018z 
                 distracted2018_rz w_productive2018z wkfamilyconfl2018z jobsatis2018z /solution clparm; 
title "&outcome.";
run;
%mend;

%linear(outcome=distracted2019_rz);
%linear(outcome=w_productive2019z);
%linear(outcome=wkfamilyconfl2019z);
%linear(outcome=jobsatis2019z);
run;

*team;
%macro linear(outcome);
proc glm data=table3;
class race22018c age_cat2018c gender2018(ref='male') mart_status2018c educ2018c home2018c no_animal2018c/ref=first;
model &outcome.= work_home2018d1 work_home2018d2 work_home2018d1*w_team2018z work_home2018d2*w_team2018z
                 gender2018 n_children2018z n_elders2018z no_animal2018c purpose2018z
                 work_hours2018c w_meaning2018z w_recognized2018z w_team2018z 
                 age_cat2018c  race22018c mart_status2018c educ2018c home2018c depressed2018z physhlth2018z 
                 distracted2018_rz w_productive2018z wkfamilyconfl2018z jobsatis2018z /solution clparm; 
title "&outcome.";
run;
%mend;

%linear(outcome=distracted2019_rz);
%linear(outcome=w_productive2019z);
%linear(outcome=wkfamilyconfl2019z);
%linear(outcome=jobsatis2019z);
run;



